<?php

class Core_Backend_Component_Media_View_Video_Create extends Core_Backend_Share_View_Form {

    public function __construct() {
        parent::__construct();
        $this->setTemplatePath('edit');
    }

    protected function buildNavigation($navigation) {
        $navigation->addLabel($this->__('media.title.video_create'));
        parent::buildNavigation($navigation);
    }

    protected function buildToolbar($toolbar) {
    	$group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('media/video/index'), $this->__('share.button.back'));
        if($this->getIdentity()->isAllowAction('media_video_edit')){
	        $group = $toolbar->createGroup('save');
	        $group->addButton($this->__('share.button.submit'))
	        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(array('status'=>'pending'), 'save')."')");
	        $group->addButton($this->__('share.button.save'))
	        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(array('status'=>'draft'), 'save')."')");
        }
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('video_form')
                ->addHiddenField('id', 'video[id]');
        $form->addTextboxField($this->__('share.label.title'), 'name', 'video[name]', TRUE)->addRequiredRule();
        $form->addTextboxField($this->__('share.label.url'), 'url', 'video[url]')->addUrlRule();
        $form->addTextboxField($this->__('share.label.tag'), 'tag', 'video[tag]');
        $form->addTextareaField($this->__('media.label.script'), 'script', 'video[script]')
                ->setStyle('height', 400);
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
        }
        parent::buildForm($form);
    }

}